package org.example.forum.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.forum.common.AppResult;
import org.example.forum.exception.ApplicationException;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/test")
@Tag(name = "测试类的相关接口")
public class TestController {
    @Operation(summary = "测试接口1")
    @GetMapping("/exception")
    public AppResult textException() throws Exception {
        throw new Exception("测试异常Exception————");
    }

    @Operation(summary = "测试接口2")
    @GetMapping("/appexception")
    public AppResult textApplicationException() throws Exception {
        throw new ApplicationException("测试异常ApplicationException————");
    }

    @PostMapping("/hello")
    @Operation(summary = "hello接口")
    public String hello(@Parameter(ref = "要传入的姓名") @RequestParam("name") String name) {
        return "hello " + name;
    }
}
